#ifndef WEBSOCKETSERVER_H
#define WEBSOCKETSERVER_H

#include <QWebSocketServer>
#include <QProtobufSerializer>
#include <QObject>

#include "data.h"

class WebsocketServer : public QObject
{
    Q_OBJECT

public:
    static WebsocketServer* getInstance();

    bool init();

private:
    static WebsocketServer* instance;
    // 第一个参数是名字，第二个参数是是否开启HTTPS加密
    WebsocketServer() : websocketServer("websocket server", QWebSocketServer::NonSecureMode) {}
    QWebSocketServer websocketServer;
    QProtobufSerializer serializer;

    int messageIndex = 0;

signals:
    void sendTextResp();
    void sendImageResp();
    void sendFileResp();
    void sendSpeechResp();
    void sendFriendRemove();
    void sendAddFriendApply();
    void sendAddFriendProcess(bool agree);
    void sendCreateChatSession();
};

#endif // WEBSOCKETSERVER_H
